/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class ordinaryA {
  field: string;

  constructor(field: string) {
    this.field = field;
  }

  m(arg: number): void {
    console.log(`Method m called with argument ${arg}`);
  }

  static sf(arg: number): void {
    console.log(`Static method sf called with argument ${arg}`);
  }

  get a(): string {
    return this.field;
  }

  set a(v: string) {
    this.field = v;
  }
}

export const instance = new ordinaryA("initial value");


class TheModifierA {
  public field: string;
  private readonly r: string;

  private m(arg: number): void {
    console.log(`Private method m called with argument ${arg}`);
  }

  protected p(arg: number): void {
    console.log(`Protected method p called with argument ${arg}`);
  }

  constructor(field: string, r: string) {
    this.field = field;
    this.r = r;
  }
}

export const TheModifierInstance = new TheModifierA("public field", "readonly field");


abstract class abstractA {
  abstract foo(): string;

  bar(): string {
    return "Bar method called"
  }
}

class abstractB extends abstractA {
  foo(): string {
    return "Foo method called"
  }
}

const instanceAbstract = new abstractB();

export const resultAbstract = instanceAbstract.foo();


class overrideA {
  foo(arg: number): string {
    return `Base foo called with argument ${arg}`;
  }
}
class overrideC extends overrideA {
  override foo(arg: number): string {
    return `Override foo called with argument ${arg}`;
  }
}
const instanceOverride = new overrideC();
export const resultOverride = instanceOverride.foo(5);



interface Inface {
  method(arg: number): string;
}
class InfaceA implements Inface {
  method(arg: number): string {
    return `Method called with argument ${arg}`;
  }
}
const instanceInface = new InfaceA();
export const InfaceResult=instanceInface.method(10);